/*
 * Gui2.java
 *
 * Created on October 31, 2008, 1:48 PM
 */
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
import java.io.*;


/**
 *
 * @author  kushwaham1
 */
public class Gui2 extends javax.swing.JFrame implements Runnable{
    String BuddyId;
    Gui0 myGui0;
    Gui1 myGui1;
    /** Creates new form Gui2 */
    public Gui2(String BuddyId, Gui0 myGui0, Gui1 myGui1) {
        initComponents();
        setTitle(BuddyId+"'s"+"Chat Window");
        setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        this.BuddyId=BuddyId;
        this.myGui0=myGui0;
        this.myGui1=myGui1;
        
    }
    public void updateMessage(String BuddyId,String msg){
        String temp=null;
        temp+=BuddyId+":"+msg;
        jTextArea2.append(temp);
    }
//    Gui2(Object BuddyId) {
//        throw new UnsupportedOperationException("Not yet implemented");
//    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextArea2 = new javax.swing.JTextArea();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem12 = new javax.swing.JMenuItem();
        jMenuItem13 = new javax.swing.JMenuItem();
        jMenuItem14 = new javax.swing.JMenuItem();
        jMenuItem21 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem11 = new javax.swing.JMenuItem();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItem2 = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItem4 = new javax.swing.JCheckBoxMenuItem();
        jCheckBoxMenuItem6 = new javax.swing.JCheckBoxMenuItem();
        jMenu4 = new javax.swing.JMenu();
        jMenuItem16 = new javax.swing.JMenuItem();
        jMenuItem15 = new javax.swing.JMenuItem();
        jMenuItem17 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        jMenuItem18 = new javax.swing.JMenuItem();
        jMenuItem19 = new javax.swing.JMenuItem();
        jMenuItem24 = new javax.swing.JMenuItem();
        jMenuItem23 = new javax.swing.JMenuItem();
        jMenuItem20 = new javax.swing.JMenuItem();
        jMenuItem22 = new javax.swing.JMenuItem();
        jMenu6 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu7 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Buddy Display Image");
        jLabel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        jLabel2.setText("My Display Image");
        jLabel2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        jLabel3.setText("Webcam If available");
        jLabel3.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 103, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jButton1.setText("Block");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Ignore(evt);
            }
        });

        jButton2.setText("Call");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Call(evt);
            }
        });

        jButton3.setText("View WebCam");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                WebCam(evt);
            }
        });

        jButton4.setText("Options");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OpeningOption(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButton4)
                .addContainerGap(26, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
                    .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
                    .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE))
                .addContainerGap())
        );

        jButton5.setText("Send");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Send(evt);
            }
        });

        jTextArea2.setColumns(20);
        jTextArea2.setRows(5);
        jScrollPane2.setViewportView(jTextArea2);

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 330, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE))
                .addContainerGap())
        );

        jMenu1.setText("File");

        jMenuItem12.setText("Send Message");
        jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Send(evt);
            }
        });
        jMenu1.add(jMenuItem12);

        jMenuItem13.setText("Save As");
        jMenuItem13.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaveAs(evt);
            }
        });
        jMenu1.add(jMenuItem13);

        jMenuItem14.setText("Print");
        jMenuItem14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Print(evt);
            }
        });
        jMenu1.add(jMenuItem14);

        jMenuItem21.setText("Exit");
        jMenuItem21.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ChatExit(evt);
            }
        });
        jMenu1.add(jMenuItem21);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");

        jMenuItem5.setText("Undo");
        jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Undo(evt);
            }
        });
        jMenu2.add(jMenuItem5);

        jMenuItem6.setText("Cut");
        jMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Cut(evt);
            }
        });
        jMenu2.add(jMenuItem6);

        jMenuItem11.setText("Copy");
        jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Copy(evt);
            }
        });
        jMenu2.add(jMenuItem11);

        jMenuItem10.setText("Paste");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Paste(evt);
            }
        });
        jMenu2.add(jMenuItem10);

        jMenuItem8.setText("Delete");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Delete(evt);
            }
        });
        jMenu2.add(jMenuItem8);

        jMenuItem7.setText("Select All");
        jMenuItem7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectAll(evt);
            }
        });
        jMenu2.add(jMenuItem7);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("View");

        jCheckBoxMenuItem1.setSelected(true);
        jCheckBoxMenuItem1.setText("Show/Hide Font ToolBar");
        jCheckBoxMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ShowFont(evt);
            }
        });
        jMenu3.add(jCheckBoxMenuItem1);

        jCheckBoxMenuItem2.setSelected(true);
        jCheckBoxMenuItem2.setText("Show/Hide Emotions Toolbar");
        jCheckBoxMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ShowEmotion(evt);
            }
        });
        jMenu3.add(jCheckBoxMenuItem2);

        jCheckBoxMenuItem4.setSelected(true);
        jCheckBoxMenuItem4.setText("Show/Hide Time Stamps");
        jCheckBoxMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ShowTimeStamp(evt);
            }
        });
        jMenu3.add(jCheckBoxMenuItem4);

        jCheckBoxMenuItem6.setSelected(true);
        jCheckBoxMenuItem6.setText("Show/Hide Recent Messages");
        jCheckBoxMenuItem6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ShowRecent(evt);
            }
        });
        jMenu3.add(jCheckBoxMenuItem6);

        jMenuBar1.add(jMenu3);

        jMenu4.setText("Buddy");

        jMenuItem16.setText("Open Contact Card for buddy");
        jMenuItem16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ContactCard(evt);
            }
        });
        jMenu4.add(jMenuItem16);

        jMenuItem15.setText("Ignore/Block buddy");
        jMenuItem15.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Ignore(evt);
            }
        });
        jMenu4.add(jMenuItem15);

        jMenuItem17.setText("Show Conversation Logs");
        jMenuItem17.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ShowConversationLog(evt);
            }
        });
        jMenu4.add(jMenuItem17);

        jMenuItem9.setText("Delete Conversation Logs");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DeleteConversationLog(evt);
            }
        });
        jMenu4.add(jMenuItem9);

        jMenuBar1.add(jMenu4);

        jMenu5.setText("Actions");

        jMenuItem18.setText("Call Computer");
        jMenuItem18.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Call(evt);
            }
        });
        jMenu5.add(jMenuItem18);

        jMenuItem19.setText("Call Settings");
        jMenuItem19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CallSetting(evt);
            }
        });
        jMenu5.add(jMenuItem19);

        jMenuItem24.setText("Invite to View Webcam");
        jMenuItem24.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                InviteWebcam(evt);
            }
        });
        jMenu5.add(jMenuItem24);

        jMenuItem23.setText("View Webcam");
        jMenuItem23.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                WebCam(evt);
            }
        });
        jMenu5.add(jMenuItem23);

        jMenuItem20.setText("Webcam Settings");
        jMenuItem20.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                WebcamSetting(evt);
            }
        });
        jMenu5.add(jMenuItem20);

        jMenuItem22.setText("Invite to Conference");
        jMenuItem22.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                InviteConference(evt);
            }
        });
        jMenu5.add(jMenuItem22);

        jMenuBar1.add(jMenu5);

        jMenu6.setText("Tools");

        jMenuItem2.setText("Fonts Setting");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FontSetting(evt);
            }
        });
        jMenu6.add(jMenuItem2);

        jMenuItem3.setText("Emotions Settings");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EmotionSetting(evt);
            }
        });
        jMenu6.add(jMenuItem3);

        jMenuItem4.setText("All Preferences");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AllPreference(evt);
            }
        });
        jMenu6.add(jMenuItem4);

        jMenuBar1.add(jMenu6);

        jMenu7.setText("Help");

        jMenuItem1.setText("Call Manish for further Assistance");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CallManish(evt);
            }
        });
        jMenu7.add(jMenuItem1);

        jMenuBar1.add(jMenu7);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void Ignore(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Ignore
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Buddy Ignored from Now");
    }//GEN-LAST:event_Ignore

    private void Call(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Call
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Calling Buddy, yet to be updated");
    }//GEN-LAST:event_Call

    private void WebCam(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WebCam
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Viewing buddy's Webcam");
    }//GEN-LAST:event_WebCam

    private void OpeningOption(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OpeningOption
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Opening Options");
    }//GEN-LAST:event_OpeningOption

    private void Send(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Send
        // TODO add your handling code here:
        
        if (jTextArea1.getText().equalsIgnoreCase("")){
            JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Please Type some msg to send");
        }
        else{
            JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Trying to Send Message");
            String serverName;
            String response;
            BufferedReader in;
            PrintWriter out;
            Socket clientSocket = null;
            try{
                System.out.println("*******************");
                System.out.println("connecting to other host");
                //serverName = "localhost";
                clientSocket = new Socket(Gui0.serverName, 2000);
                in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                out = new PrintWriter(clientSocket.getOutputStream(), true);
                out.println("Get IP Address"+","+BuddyId);
                String IpAddress= in.readLine();
                System.out.println("Got the Ip Address");
                System.out.println("Server returns IP Address:"+ IpAddress);
                out.println("Get Port number"+","+BuddyId);
                String portNumber=in.readLine();
                int portNumbers = Integer.parseInt(portNumber);
                System.out.println("Server returned portnumbers as:"+portNumbers);
                clientSocket.close();
                in.close();
                out.close();
                System.out.println("Closing connection and starting a new one");
                //JOptionPane.showMessageDialog(new javax.swing.JFrame(), "So got the IP & port from the server");
                clientSocket = new Socket(IpAddress,portNumbers);
                in = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                out = new PrintWriter(clientSocket.getOutputStream(), true);
                String addMsg=null;
                addMsg+=myGui0.getUserId()+":"+jTextArea1.getText();
                jTextArea2.append(addMsg);
                out.println("Message"+myGui0.getUserId()+","+jTextArea1.getText());
            }
            catch (IOException e){
                System.out.println("Error in communication in Gui2");
            }    
        }

        
    }//GEN-LAST:event_Send

    private void SaveAs(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveAs
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Opening Dialog to select Files");
    }//GEN-LAST:event_SaveAs

    private void Print(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Print
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Go to the printer, it's coming");
    }//GEN-LAST:event_Print

    private void ChatExit(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ChatExit
        // TODO add your handling code here:
        dispose();
    }//GEN-LAST:event_ChatExit

    private void Undo(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Undo
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_Undo

    private void Cut(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Cut
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_Cut

    private void Copy(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Copy
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_Copy

    private void Paste(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Paste
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_Paste

    private void Delete(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Delete
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_Delete

    private void SelectAll(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectAll
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_SelectAll

    private void ShowFont(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ShowFont
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_ShowFont

    private void ShowEmotion(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ShowEmotion
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_ShowEmotion

    private void ShowTimeStamp(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ShowTimeStamp
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_ShowTimeStamp

    private void ShowRecent(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ShowRecent
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_ShowRecent

    private void ShowConversationLog(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ShowConversationLog
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_ShowConversationLog

    private void DeleteConversationLog(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteConversationLog
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_DeleteConversationLog

    private void CallSetting(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CallSetting
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_CallSetting

    private void InviteWebcam(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_InviteWebcam
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_InviteWebcam

    private void WebcamSetting(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WebcamSetting
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_WebcamSetting

    private void InviteConference(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_InviteConference
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_InviteConference

    private void FontSetting(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FontSetting
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_FontSetting

    private void EmotionSetting(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EmotionSetting
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_EmotionSetting

    private void AllPreference(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AllPreference
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_AllPreference

    private void CallManish(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CallManish
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_CallManish

    private void ContactCard(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ContactCard
        // TODO add your handling code here:
        JOptionPane.showMessageDialog(new javax.swing.JFrame(), "Yet to be Updated");
    }//GEN-LAST:event_ContactCard

    /**
    * @param args the command line arguments
    */
    /**
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Gui2().setVisible(true);
            }
        });
    }
     */

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem2;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem4;
    private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem6;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenu jMenu6;
    private javax.swing.JMenu jMenu7;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem11;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem13;
    private javax.swing.JMenuItem jMenuItem14;
    private javax.swing.JMenuItem jMenuItem15;
    private javax.swing.JMenuItem jMenuItem16;
    private javax.swing.JMenuItem jMenuItem17;
    private javax.swing.JMenuItem jMenuItem18;
    private javax.swing.JMenuItem jMenuItem19;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem20;
    private javax.swing.JMenuItem jMenuItem21;
    private javax.swing.JMenuItem jMenuItem22;
    private javax.swing.JMenuItem jMenuItem23;
    private javax.swing.JMenuItem jMenuItem24;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea2;
    // End of variables declaration//GEN-END:variables

    public void run() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

}
